# Contributor: nezu <nezu@nezu.cc>
# Maintainer: nezu <nezu@nezu.cc>
pkgname=aero2solver
pkgver=1.0.0
pkgrel=0
pkgdesc="Automatic captcha solver for aero2.pl"
url="https://github.com/dumbasPL/aero2solver"
# s390x: builds, but inference fails
arch="all !s390x"
license="MIT"
makedepends="cargo cargo-auditable cmake clang-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/dumbasPL/aero2solver/archive/refs/tags/v$pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd
	$pkgname.logrotate
	"
options="net"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	MODEL_PATH=/usr/share/$pkgname/model \
		cargo auditable build --frozen --release
}

check() {
	cargo test --frozen
}

package() {
	install -m755 -D target/release/$pkgname \
		-t "$pkgdir"/usr/bin/

	install -m644 -D model/captcha.cfg \
		-t "$pkgdir"/usr/share/$pkgname/model/
	install -m644 -D model/captcha.names \
		-t "$pkgdir"/usr/share/$pkgname/model/
	install -m644 -D model/captcha.weights \
		-t "$pkgdir"/usr/share/$pkgname/model/

	install -m644 -D LICENSE \
		-t "$pkgdir"/usr/share/licenses/$pkgname/

	install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.logrotate \
		"$pkgdir"/etc/logrotate.d/$pkgname
}

sha512sums="
d319eadf9908adc6bee4ef184226ee7b7371095fe03e204141718b90d01aeafec85c9fae1aacc04c8e67570e1c93ae916e5c3aa8a6d0bc2794e10becdd802734  aero2solver-1.0.0.tar.gz
5183024b38e2b2257b23f82caec82baeb2ebf8c53238c9ce52f32f790909c30f40f2ea47a58bc861da08f84dd861434faeeeb617b0463e17794dc2aa6502d1b3  aero2solver.initd
9ab94bc219108505264d94c396e979ab54da29fe8adebee247d747bd0035242d7aec6fe4e43a7f297667b51520edd6621167a7dab75987a2fd9ff587368aa2e4  aero2solver.confd
466789dc2f8877bf04e2bbf0ef142f4cb4b70b1021def3deec39fa854e9661f0c0d583030ceebb4916996c8af4ea1df9a1b3a3d130223c3eea1a23737adba39a  aero2solver.logrotate
"
